package com.api.base.controll;
import com.api.base.model.States;
import com.api.base.service.StatesService;
import com.api.core.controller.Ctrl;
import com.api.core.response.Result;
import com.api.core.response.ResultGenerator;
import com.api.base.model.Countries;
import com.api.base.service.CountriesService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
import com.api.core.annotation.PowerEnable;
import io.swagger.annotations.*;



/**
* Created by wanghuiwen on 2021/05/07.
*/
@PowerEnable(name = "国家",url = "/countries")
@Api(value = "国家", tags = {"国家"})
@RestController
@RequestMapping("/countries")
public class CountriesController extends Ctrl{

    @Resource
    private CountriesService countriesService;

    @Resource
    private StatesService statesService;


    @PostMapping(value = "/all", name = "列表")
    @ResponseBody
    public Result all(){


        return ResultGenerator.genSuccessResult(countriesService.findAll());
    }
    @PostMapping(value = "/states", name = "列表")
    @ResponseBody
    public Result states(@RequestParam Long countryId){

        List<States> states = statesService.findByCountryId(countryId);

        return ResultGenerator.genSuccessResult(states);
    }
}
